using System;
using System.Text;
using System.Web.Mvc;
using Wikey.Domain.Components;
using Wikey.Extensibility.Classes;
using Wikey.Transformation;
using Factory=Wikey.Domain.Components.Factory;

namespace Wikey.Web.Mvc.Controllers
{
    
    public class DataController : Controller
    {
        [OutputCache(Duration = 180, VaryByParam = "test")]
        [CompressFilter]
        public ActionResult Get( string source , string type  )
        {
            return Factory.Get<IDynamicDataSource>().Get(source, type);
        }
        
        [CompressFilter]
        [AcceptVerbs(HttpVerbs.Get)]
        public JsonResult Expression(string source, string type)
        {
            
            var jsonResult = new JsonResult();
            jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            jsonResult.Data = new Transform().Do(source);
            jsonResult.ContentType = typeof(TransformationResult).ToString();
            jsonResult.ContentEncoding = Encoding.GetEncoding("utf-8");

            return jsonResult;

        }
    }

   

    
}
